﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Speech.Recognition;
using System.Speech.Synthesis;
using System.Text;
using System.Threading.Tasks;

namespace luck_roll
{
    public class LuckSoundPlayer
    {
        private String content = String.Empty;
        public LuckSoundPlayer(string playContent)
        {
            this.content = playContent;
        }


        public void Speek() {

            try
            {
                SpeechRecognitionEngine recEngine = new SpeechRecognitionEngine();
                SpeechSynthesizer speech = new SpeechSynthesizer();
                speech.Rate = 0;//速度
                speech.Volume = 100;//音量,0-100

                speech.SpeakAsync(content);//异步播放
              
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Console.WriteLine(ex);
            }
        }
    }
}
